home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / LinkList / c / InsertB < prev    next >
Text File  |  1995-07-08  |  1KB  |  43 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    LinkList.InsertB.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.02 (16 Mar 1992)
  14.     Purpose: Linked list handling functions
  15. */
  16.  
  17.  
  18. #include <stdlib.h>
  19. #include <stdio.h>
  20.  
  21. #include "DeskLib:LinkList.h"
  22.  
  23.  
  24. extern void LinkList_InsertBefore(linklist_header *anchor,
  25.                                   linklist_header *pos,
  26.                                   linklist_header *item)
  27. {
  28.   linklist_header *oldprev;
  29.  
  30.   oldprev = pos->previous;
  31.  
  32.   if (oldprev == NULL)                             /* Insert at head of list */
  33.     LinkList_AddToHead(anchor, item);
  34.   else
  35.   {
  36.     oldprev->next  = item;                         /* Link to prev in list   */
  37.     item->previous = oldprev;
  38.  
  39.     pos->previous  = item;                         /* Link "pos" in as next  */
  40.     item->next     = pos;
  41.   }
  42. }
  43.